function ShowView(options){
	this.showview=$(ShowView.WRAPPER);
	this.options=$.extend({},ShowView.DEFAULTS,options||{});
	$.data(this.showview[0],"iview",this);
	this.setView();	
}
ShowView.EF=function(){};
$.extend(ShowView,{
	WRAPPER:'<div class="iview_box">'
				+'<div class="iview_head">'
					+'<a href="#" class="logo" title="笔飞美术作品"><img src="../images/logo2.jpg" alt="笔飞美术作品"></a>'
					+'<a href="javascript:;" class="iview_close" title="关闭">close</a>'
				+'</div>'
				+'<div class="iview_btn">'
        			+'<a href="javascript:;" class="iview_zoom_in ht" id="iview_zi" title="放大">放大</a>'
            		+'<a href="javascript:;" class="iview_zoom_out ht" id="iview_zo" title="缩小">缩小</a>'
            		+'<a href="javascript:;" class="iview_reset ht" id="iview_reset" title="重置">重置</a>'
        		+'</div>'
				+'<div class="iview_con">'
					+'<div class="iview_img_wrap" id="iview_img_container"></div>'
				+'</div>'
				+'<div class="iview_foot">'
					+'<h2></h2>'
				+'</div>'
			+'</div>',
	iviewMask:'<div class="iview_mask"></div>',
	DEFAULTS:{
		title:"",
		imgSrc:"",
		unloadOnHide:false,
		loadComplete:ShowView.EF,
		afterHide:ShowView.EF,
		afterShow:ShowView.EF
		
	},
	_checkWidHei:function(){},
	getView:function(ele){
		return ele.length?$.data(ele[0],"iview"):null; 	
	},
	operateWin:function(isBool){
		$("body").scrollTop(0);
		$("html").scrollTop(0);
		if(isBool){
			$("html").css({"overflow":"hidden"});
			$("body").css({"overflow":"hidden"});	
		}else{
			$("html").css({"overflow":"auto"});
			$("body").css({"overflow":"auto"});		
		}
	},
	_viewPort:function(){
		return [$(window).width(),$(window).height()];	
	}
});

ShowView.prototype={
	unload:function(){
		//移除绑定事件，并移除元素
		this.showview.find(".iview_close").unbind("click.iview");
		$("div.iview_mask").remove();
		this.showview.remove();	
	},
	
	show:function(){
		if(this.visible) return;
		var self=this;
		ShowView.operateWin(true);
		this.showview.css({"display":"block"});
		$("div.iview_mask").css({"display":"block"});
		$("div.iview_mask").animate({
			opacity:1	
		});
		this.showview.animate({
			opacity:1	
		},function(){
			self.visible=true;	
		});
		this._fire("afterShow");
		
		return this;
	},
	hide:function(after){
		if(!this.visible) return;
		var self=this;
		ShowView.operateWin(false);
		$("div.iview_mask").animate({"opacity":0},function(){
			$("div.iview_mask").css({"display":"none"});
		});
		this.showview.animate({
			opacity:0	
		},function(){
			self.showview.css({"display":"none"});
			self.visible=false;
			if(self.options.unloadOnHide){
				
				self.unload();
			}
			
		});
		this._fire("afterHide");
		if(after){
			after(self);	
		}
		return this;		
	},
	resize:function(){},
	setView:function(){
		var ie6=$.browser.msie&&$.browser.version=="6.0";
		this.showview.find("div.iview_foot h2").html(this.options.title);
		this._setupDefaultBehavious();
		$("body").append($(ShowView.iviewMask));
		if(ie6){
			var vp=ShowView._viewPort();
			$("div.iview_mask").css({height:vp[1]+"px"});
			this.showview.css({height:vp[1]+"px"});
			this.showview.find("div.iview_img_wrap").css({height:(vp[1]-150)+"px"});
		}
		$("body").append(this.showview);
		this.show();	
	},
	isVisible:function(){
		return this.visible;	
	},
	_setupDefaultBehavious:function(){
		var self=this;
		this.showview.find(".iview_close").bind("click.iview",function(){
			self.hide();
		});	
	},
	_fire:function(event){
		this.options[event].call(this);	
	}
}
